#coding: utf-8
'''
Created on 2013-6-19

@author: WWG
'''

import urllib2
import BeautifulSoup
import re

name = "xunwuxia"
losturl = "http://xunwuxia.com/lost-list.html"

usrfile =open(name+'usr'+timestamp,'w')
lostitemfile =open(name+'lost'+timestamp,'w')

lostList = urllib2.urlopen(losturl).read().decode("UTF-8")


match = re.findall(r'(detail-lost-found-\d+.html)">(.+)</a',lostList)
if match:
    print match
    for item in match:
        itemurl =item[0]
        itemBase =item[1]
        
        lostItem =urllib2.urlopen(itemurl).read().decode("UTF-8")
        'analysis by beautifulSoup and store in db'
        usr= {'url':itemurl,
              'type':1,
              'src':name} 
        
        '转成json格式，存到mysql'
        
        '没有id,插入数据库自动建立id'
        
        
        soup = BeautifulSoup.BeautifulStoneSoup(lostItem)
        '''
        parse the html and store
        '''
        
      
        usrfile.write(usr)
        
        
        
        
        
        
        
        

'''




lostFile = open(lostName+"lost", 'w')
lostFile.write(lostList)
lostFile.close()'''

